package com.collectionAndMap.map;

import java.util.TreeMap;

/***
 * @ClassName: TerrMapDemo
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 14:33 2022/2/18
 * @version : V1.0
 */
public class TerrMapDemo {
    public static void main(String[] args) {
        //这里用lambda表达式，也可以再User对象上实现Comparable<User>
        TreeMap<User, Object> map = new TreeMap<>((x,y)->{
           int m = x.getAge()-y.getAge();
            int n = x.getName().compareTo(y.getName());
            //先比年龄
            return m==0?n:m;
        });
        User a = new User("小红", 33);
        User b = new User("小蓝", 7);
        User c = new User("小绿", 7);
        User d = new User("小紫", 4);
        map.put(a,"aaa");
        map.put(b,"bbb");
        map.put(c,"ccc");
        System.out.println(map.put(d, "ddd"));
        System.out.println(map);
        System.out.println((int)'绿');
        System.out.println((int)'蓝');
    }
}
